package com.qf.demo;

import com.qf.service.AccountService;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;

public class AccountDemo {
    public static void main(String[] args) {
//        ApplicationContext applicationContext=new ClassPathXmlApplicationContext("bean.xml");
//        AccountService accountService = (AccountService) applicationContext.getBean("accountService");
//        accountService.addAccount();
        //顶层容器是BeanFactory
        Resource classPathResource = new ClassPathResource("bean.xml");

        BeanFactory beanFactory = new XmlBeanFactory(classPathResource);
        AccountService accountService= (AccountService) beanFactory.getBean("accountService");

        System.out.println(accountService);
    }
}
